package com.huaxin.hxmoduleworkorder.dto.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.huaxin.hxmoduleworkorder.common.enums.MaintenanceOrderOperation;
import com.huaxin.hxmoduleworkorder.common.enums.MaintenanceOrderOperatorRole;
import com.huaxin.hxmoduleworkorder.common.enums.MaintenanceOrderStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Builder;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 新增维修流程记录请求 DTO
 * <p>
 * 对应实体类：MaintenanceOrderProcess
 * 用于记录维修工单在处理过程中的每一步操作（如分配、接单、完成等）。
 * 所有字段命名与实体类完全一致，确保映射准确。
 * 使用 jakarta.validation 进行参数校验。
 * </p>
 *
 * @author [你的名字或团队]
 * @since 2025-09-02
 */
@Data
@Builder
public class MaintenanceOrderProcessCreateReqDTO {
    @Schema(description = "维修工单ID，关联的工单", example = "mnt_order_001")
    @NotBlank(message = "维修工单ID不能为空")
    @Size(max = 50, message = "维修工单ID长度不能超过50个字符")
    private String MaintenanceOrderId;

    @Schema(description = "执行动作", example = "assign")
    private MaintenanceOrderOperation action;

    @Schema(description = "变更前状态：created/reviewing/assigned/reassign/processing/resolved/evaluating/completed/rejected/cancelled/rollback", example = "created")
    private MaintenanceOrderStatus fromStatus;

    @Schema(description = "变更后状态：created/reviewing/assigned/reassign/processing/resolved/evaluating/completed/rejected/cancelled/rollback", example = "assigned")
    private MaintenanceOrderStatus toStatus;

    @Schema(description = "操作者角色：customer（客户）/admin（管理员）/electrician（电工）", example = "admin")
    private MaintenanceOrderOperatorRole operatorRole;

    @Schema(description = "操作者ID，关联的用户ID", example = "user_001")
    @NotBlank(message = "操作者ID不能为空")
    @Size(max = 50, message = "操作者ID长度不能超过50个字符")
    private String operatorId;

    @Schema(description = "操作者经度", example = "116.397128")
    private String operatorLongitude;

    @Schema(description = "操作者纬度", example = "39.915119")
    private String operatorLatitude;

    @Schema(description = "备注，如审核意见、处理说明等", example = "已分配给张师傅")
    @Size(max = 1000, message = "备注长度不能超过1000个字符")
    private String remarks;

    @Schema(description = "该步骤是否完成：0-未完成，1-已完成", example = "1")
    @NotNull(message = "是否完成字段不能为空")
    private Integer isCompleted;

    @Schema(description = "下一步预计完成时间", example = "2025-09-02T15:00:00")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime nextStepDueTime;
}